package com.jewaton.auth.commons.entity;


import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * 角色权限表
 */
@Entity
@Table(name = "ROLE_PERMISSION")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class RolePermission implements java.io.Serializable {

	private long rpid;
	private Permission permission;
	private Role role;

    @Id
    @GeneratedValue(strategy = IDENTITY)
	@Column(name = "RPID", unique = true, nullable = false, precision = 10, scale = 0)
	public long getRpid() {
		return this.rpid;
	}

	public void setRpid(long rpid) {
		this.rpid = rpid;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "PID", nullable = false)
	public Permission getPermission() {
		return this.permission;
	}

	public void setPermission(Permission permission) {
		this.permission = permission;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "RID", nullable = false)
	public Role getRole() {
		return this.role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

}
